<?php
// 用户宠物信息列表
// header("content-type:text/html;charset=UTF-8");
include_once("conn.php");
include_once("u_getLoginInfo.php");

$select_pet = "SELECT * FROM pet_infos WHERE user_ID = '$userID'";

$result_pet = mysqli_query($connect_DB, $select_pet);
if ($result_pet) {
    if (mysqli_num_rows($result_pet) <= 0) {
        echo "<div class='none-tips'>暂无您的宠物列表信息</div>";
    } else {
        while ($row_pet = mysqli_fetch_object($result_pet)) {
            if (substr($row_pet->pet_PhotoAddress, 0, 3) != "pet") {
                $src = "../public/pic/pet_photos/" . $row_pet->pet_PhotoAddress;
            } else {
                $src = "../public/pic/pet_photos/" . $userID . "/" . $row_pet->pet_PhotoAddress;
            }
            echo "
            <div class='petinfo-div'>
                <div class='petinfo-div-left'>
                    <div class='photo-div'>
                        <img src='" . $src . "' alt='图片跑丢了QAQ'>
                    </div>
                    <div class='name-div'>" . $row_pet->pet_Name . "</div>
                </div>
                <div class='petinfo-div-right'>
                    <p><span>宠物 ID：</span>" . $row_pet->pet_ID . "</p>
                    <p><span>宠物生日：</span>" . $row_pet->pet_Birthday . "</p>
                    <p><span>添加日期：</span>" . $row_pet->pet_AddDate . "</p>
                    <p><span>所属类型：</span>" . $row_pet->pet_Type . "</p>
                    <a href='u_changePetInfo.php?action=del&petID=" . $row_pet->pet_ID . "'><button type='button' class='btn btn-primary' onclick='return delBtn()'>删除该宠物信息</button></a>
                    <a href='user_changePetInfo.php?petID=" . $row_pet->pet_ID . "&petName=".$row_pet->pet_Name."&petBir=".$row_pet->pet_Birthday."'><button type='button' class='btn btn-primary'>修改宠物信息</button></a>
                </div>
            </div>
            ";
        }
    }
} else {
    echo "<div class='none-tips'>无法查询宠物列表信息<br>" . $select_pet . "</div>";
}
$connect_DB->close();
?>